<?php
/**
 * Cache_Backend_Memcached
 * 
 * 作者:  姚刚 (yaogang@the9sense.com)
 * 创建时间: 2011-02-24 00:20:14
 * 修改记录: yiguopan
 * 
 * $Id: Memcached.php 9 2011-03-16 05:32:19Z yiguopan2 $
 */

class Cache_Backend_Memcached extends Cache_Backend_Abstract{
	public function connect($conf) {
		$this->mc = new Memcached;
		$this->mc->addServers($servers);
		// 设置非阻塞传输模式
		$this->mc->setOption(Memcached::OPT_NO_BLOCK, true);
		// 设置连接超时
		$this->mc->setOption(Memcached::OPT_CONNECT_TIMEOUT, 200);
		// 设置POLL超时
		$this->mc->setOption(Memcached::OPT_POLL_TIMEOUT, 50);
	}
	
	public function get($key) {
		return $this->mc->get($key);
	}
	
	public function set($key, $value, $expire, $options = array()) {
		return $this->mc->set($key, $value, $expire);
	}
	
	public function setMulti($keyAndvalue, $expire, $options = array()) {
		return $this->mc->setMulti($keyAndvalue, $expire);
	}

	public function delete($key) {
		return $this->mc->delete($key);
	}
	public function close() {
		$this->mc->close();
		return true;
	}
}
